package org.yx.service.smfr.view_material_sn_waitting_for_order;

import org.dbist.dml.Page;
import org.dbist.dml.Query;
import org.yx.utils.BaseService;

/**
 * 查询工单的可出库退库的原料条码
 *
 * @author zxw
 * @since 2023/03/20
 **/
public class SmfrViewMaterialSnWaittingForOrderService extends BaseService {
    public SmfrViewMaterialSnWaittingForOrderOut viewMaterialSnWaittingForOrder(SmfrViewMaterialSnWaittingForOrderIn in) throws Exception {
        Page<MsnForWorkOrder> moMsnPage = null;

        Query query = new Query(in.getPageIndex(), in.getPageSize());
        query.addFilter("orgCode", in.getUserOrgCode());
        query.addFilter("mo", in.getMo());
        query.addFilter("matCode", in.getMatCode());
        query.addFilter("msn", in.getMsn());
        if ("O".equals(in.getIoType())) {
            moMsnPage = selectPageBySqlFilePath("select_msn_waitting_for_mo_request", query, MsnForWorkOrder.class);
        } else {
            moMsnPage = selectPageBySqlFilePath("select_msn_waitting_for_mo_return", query, MsnForWorkOrder.class);
        }

        SmfrViewMaterialSnWaittingForOrderOut out = new SmfrViewMaterialSnWaittingForOrderOut();
        if (moMsnPage != null) {
            out.setMsnList(moMsnPage.getList());
            out.setTotal(moMsnPage.getTotalSize());
        }

        return out;
    }
}